//
//  EvaluateCellFrame.m
//  MM
//
//  Created by 郑渊文 on 6/1/15.
//  Copyright (c) 2015 王晨辉. All rights reserved.
//
#import "EvaluateCellFrame.h"
#import "EvaluateModel.h"

#define FONTSIZE(size) [UIFont systemFontOfSize:(size)]   //字体大小
#define LEFT_MARGIN 15                                    //内容左边距
#define CONTENT_TOP_MARGIN 15                             //评价内容上边距
#define USER_TOP_MARGIN 15
#define EVELUATETIME_LEFT_MARGIN 10                      //评价时间左边距
#define CELL_BOTTOM_MARGIN 10

@implementation EvaluateCellFrame

- (void)setEvaluateModel:(EvaluateModel *)evaluateModel
{
    _evaluateModel = evaluateModel;
    
    CGFloat cellWidth = [[UIScreen mainScreen] bounds].size.width;
    
    //评论内容;
    CGRect contentRect = [_evaluateModel.evaluateContent boundingRectWithSize:CGSizeMake(cellWidth - LEFT_MARGIN *2, MAXFLOAT)
                                                                      options:NSStringDrawingUsesLineFragmentOrigin
                                                                   attributes:@{NSFontAttributeName:FONTSIZE(16.0f)}
                                                                      context:nil];
    
    
    
    
    _evaluateContentFrame = (CGRect){{LEFT_MARGIN,CONTENT_TOP_MARGIN},contentRect.size};
    _cellHeight = contentRect.size.height+CONTENT_TOP_MARGIN;
    
    //评价用户
    CGSize userSize = [_evaluateModel.evaluateUser sizeWithAttributes:@{NSFontAttributeName:FONTSIZE(14.0)}];
    _evaluateUserFrame = (CGRect){{LEFT_MARGIN,USER_TOP_MARGIN+contentRect.size.height+CONTENT_TOP_MARGIN},userSize};
    _cellHeight += userSize.height + USER_TOP_MARGIN;
    
    //评论时间
    CGSize timeSize = [_evaluateModel.evalateTime sizeWithAttributes:@{NSFontAttributeName:FONTSIZE(14.0)}];
    _evalateTimeFrame = (CGRect){{LEFT_MARGIN+userSize.width+EVELUATETIME_LEFT_MARGIN,USER_TOP_MARGIN+contentRect.size.height+ CONTENT_TOP_MARGIN},timeSize};
    
    //评价星
    _evaluatesStarFrame = (CGRect){{cellWidth-100,USER_TOP_MARGIN+contentRect.size.height-5+ CONTENT_TOP_MARGIN},CGSizeMake(35, 20)};
  
    _evalateUserImgFrame = (CGRect){{10,USER_TOP_MARGIN+contentRect.size.height-5+ CONTENT_TOP_MARGIN},CGSizeMake(80, 20)};
     
}


@end
